#include "Game.h"
#include <windows.h>
#include <iostream>
using namespace std;
//---------------------------------------------------------------------------------------------//
Game::Game(HINSTANCE hInstance) : BaseGame(hInstance)
{
	m_pCamera = new Camera();
}
//---------------------------------------------------------------------------------------------//
bool Game::OnStart()
{
 	m_pPointLight = new PointLight(m_graphics, D3DXVECTOR3(100,100,-150));
 	m_pPointLight->SetLight();
	
// 	m_pDirectionalLight = new DirectionalLight(m_graphics, D3DXVECTOR3(-1,1,1));
// 	m_pDirectionalLight->SetLight();
	
	m_pCube = new Cube(m_graphics);

//  	m_pSpotLight = new SpotLight(m_graphics, Vector3(0,0,0), Vector3(0,100,-100));
//  	m_pSpotLight->SetLight();
	
	rot = 0;
	cout << "start" << endl;
	return true;
}
//---------------------------------------------------------------------------------------------//
bool Game::OnUpdate()
{
	//m_pCube->Scale(Vector3(50,50,50));
	//m_pCube->Translate(D3DXVECTOR3(rot,0,0));
	//m_pPointLight->SetLight();
	rot += 0.5f;

	if(m_pInput->getKeyDown(DIK_W))
	{
		m_pCamera->Walk(5);
	}
	if(m_pInput->getKeyDown(DIK_S))
	{
		m_pCamera->Walk(-5);
	}
	if(m_pInput->getKeyDown(DIK_A))
	{
		m_pCamera->Strafe(-5);
	}
	if(m_pInput->getKeyDown(DIK_D))
	{
		m_pCamera->Strafe(5);
	}


	if(m_pInput->getKeyDown(DIK_UP))
	{
		m_pCamera->Pitch(-0.01);
	}
	if(m_pInput->getKeyDown(DIK_DOWN))
	{
		m_pCamera->Pitch(0.01);
	}
	if(m_pInput->getKeyDown(DIK_LEFT))
	{
		m_pCamera->Yaw(-0.01);
	}
	if(m_pInput->getKeyDown(DIK_RIGHT))
	{
		m_pCamera->Yaw(0.01);
	}
	m_pCamera->Draw(m_graphics);
	
	return true;
}
//---------------------------------------------------------------------------------------------//
void Game::OnDraw()
{
	m_pCube->Draw();
}
//---------------------------------------------------------------------------------------------//
void Game::OnShutDown()
{
	delete m_pCube;
	delete m_pCamera;
	//delete m_pDirectionalLight;
	cout << "shut down" << endl;
}